<template>
  <div>
    	<div class="header-return" v-show="showHeader">
			<span class="border-return"></span>
			<span class="iconfont return" @click="toHome">&#xe663;</span>
		</div>

     <div class="header" v-show="!showHeader" :style="styleOpacity">
    <div class="header-left">
      <span class="iconfont" @click="toHome">&#xe663;</span>
    </div>
    
    <div class="header-wenzi">
      北京国际鲜花港
    </div>
    
  </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      showHeader: true,
      styleOpacity: {
        opacity: 0
      }
    };
  },
  methods: {
    toHome() {
      this.$router.push("/");
    }
  },
  mounted() {
    let That = this;
    window.addEventListener("scroll", function() {
      let top = document.documentElement.scrollTop;
      if (top > 45) {
        let opacity = top / 130;
        opacity = opacity > 1 ? 1 : opacity;
        That.styleOpacity = { opacity };
        That.showHeader = false;
      } else {
        That.showHeader = true;
      }
    });
  }
};
</script>

<style lang="less" scoped>
.header-return {
  position: absolute;
  left: 0.1rem;
  top: 0.1rem;
  width: 0.72rem;
  height: 0.72rem;
}
.border-return {
  display: block;
  background: #000;
  width: 0.72rem;
  height: 0.72rem;
  opacity: 0.5;
  border-radius: 0.36rem;
}
.return {
  position: absolute;
  left: 0;
  top: 0;
  color: #fff;
  width: 0.72rem;
  line-height: 0.72rem;
  text-align: left;
  text-indent: 0.2rem;
  font-size: 0.32rem;
  font-weight: bold;
}
.header {
  position: fixed;
  top: 0;
  width: 100%;
  line-height: 0.88rem;
  background: #00bcd4;
  color: #fff;
  font-size: 0.36rem;
  display: flex;
}

.header-left {
  width: 10%;
  padding: 0 0.2rem;
  text-align: center;
  font-weight: bold;
}
.header-wenzi {
  position: absolute;
  left: 33%;
}
</style>
